package com.ciwong.epaper.modules.reciteWords.dao;

import com.ciwong.epaper.modules.reciteWords.bean.SelectVocabularyBean;
import com.ciwong.mobilelib.i.BaseCallBack;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by keepon on 2018/9/13.
 */
public class WordDao  {
	private static WordDao instance;

	private WordDao() {
	}

	/**
	 * 获取唯一实例
	 *
	 * @return 唯一实例
	 */
	public static WordDao getInstance() {
		if (instance == null) {
			syncInit();
		}
		return instance;
	}

	/**
	 * 实例化对象
	 */
	private static synchronized void syncInit() {
		if (instance == null) {
			instance = new WordDao();
		}
	}

	public void getRecitewordsVersion(final BaseCallBack callBack) {
		WordRequest.getRecitewordsVersion( new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				List<SelectVocabularyBean> clazzs = (List<SelectVocabularyBean>) data;
				callBack.success(clazzs);
			}
		});
	}
	public void getLearnCount(int userId,final BaseCallBack callBack) {
		WordRequest.getLearnCount( userId,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}

	public static void saveAndGetWordPlan(int userId,int bookId,String planName,
	                                      int dayCount,int days,final BaseCallBack callBack) {
		WordRequest.saveAndGetWordPlan( userId,bookId,planName,dayCount,days,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}
	public void submitWord(int  userId, ArrayList<Integer> wordArray, final BaseCallBack callBack) {
		WordRequest.submitWord( userId,wordArray,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}
	public void getLearnedWords( int  userId,final BaseCallBack callBack) {
		WordRequest.getLearnedWords( userId,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}
	public void getUnlearnedWords( int userId, int pageIndex, int pageSize,final BaseCallBack callBack) {
		WordRequest.getUnlearnedWords( userId,pageIndex,pageSize,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}

	public void getBookLearning( int  userId,final BaseCallBack callBack) {
		WordRequest.getBookLearning( userId,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}
	public void getAgain(int  userId,int bookId,final BaseCallBack callBack) {
		WordRequest.getAgain( userId,bookId,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}
	public void getBookLearnInfo( int  userId,int bookId,final BaseCallBack callBack) {
		WordRequest.getBookLearnInfo( userId,bookId,new BaseCallBack() {
			@Override
			public void failed(int errorCode, Object data) {
				callBack.failed(errorCode, data);
			}

			@Override
			public void failed(Object data) {
				callBack.failed(data);
			}

			@Override
			public void success(Object data) {
				callBack.success(data);
			}
		});
	}
}
